{include file="header.html"}

<div class="member-cart-pay">
	<section class="buttonView">
		<a class="btn" href="wap.php?app=member&act=index">返回会员中心</a>
		<a class="wx" href="javascript:callpay()">微信支付</a>
	</section>
</div>

{include file="footer.html"}
<script>
//调用微信JS api 支付
function jsApiCall(){
	WeixinJSBridge.invoke(
		'getBrandWCPayRequest',
		{$data},
		function(res){
			WeixinJSBridge.log(res.err_msg);
			if(res.err_msg=='get_brand_wcpay_request:ok'){
				location.href = 'wap.php?app=coffee_cart&act=order_complete&order_sn={$order_sn}';
			}else{
				//alert('支付失败， 原因：\n'+res.err_desc);
				$('.member-cart-pay a.wx').html('重新支付');
			}
		}
	);
}

function callpay(){
	if (typeof WeixinJSBridge == "undefined"){
		if( document.addEventListener ){
			document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
		}else if (document.attachEvent){
			document.attachEvent('WeixinJSBridgeReady', jsApiCall);
			document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
		}
	}else{
		jsApiCall();
	}
}

$(function(){
	callpay();
});
</script>